<?php defined('ByShopWWI') or exit('Access Invalid!');?> 


<div class="nc-register-bg">
  <div class="nc-register-box">
    <div class="nc-register-layout">
      <div class="left">
        <div class="nc-register-mode">

          <div id="tabs_container" class="tabs-container">
            <div id="default" class="ncm-default-form">
              <form id="register_form" method="post" class="nc-login-form" action="<?php echo urlLogin('login', 'usersave');?>">
                <input type="hidden" name="form_submit" value="ok" />
                <?php Security::getToken();?>
                <dl>
                  <dt>会员账号：</dt>
                  <dd>
                    <input type="text" id="user_name" name="user_name" class="text w200" />
                    <p class="hint"><?php echo $lang['login_register_username_to_login'];?></p>
                  </dd>
                </dl>
                <dl>
                  <dt>密码：</dt>
                  <dd>
                    <input type="password" id="password" name="password" class="text w200" />
                    <p class="hint"><?php echo $lang['login_register_password_to_login'];?></p>
                  </dd>
                </dl>
                <dl>
                  <dt>确认密码：</dt>
                  <dd>
                    <input type="password" id="password_confirm" name="password_confirm" class="text w200" />
                    <p class="hint"><?php echo $lang['login_register_input_password_again'];?></p>
                  </dd>
                </dl>

                <dl >
                  <dt>会员级别：</dt>
                  <dd>
                   <select id="member_type" name="member_type"> 
                        <option value="1">普通会员</option> 
                        <option value="2">贵宾会员</option> 
                        <option value="3">VIP会员</option>
                        <option value="4">店长</option>  
                   </select>
                  </dd>
                </dl>          
                <dl>
                  <dt>真实姓名：</dt>
                  <dd>
                    <input type="text" id="member_truename" name="member_truename" class="text w200" />
                    <p class="hint"><?php echo $lang['login_register_tureusername_to_login'];?></p>
                  </dd>
                </dl>

                <dl>
                  <dt>身份证号：</dt>
                  <dd>
                    <input type="text" id="identification_card" name="identification_card" class="text w200" />
                    <p class="hint"><?php echo $lang['login_register_tureusernum_to_login'];?></p>
                  </dd>
                </dl>
  
                <dl class="mt15">
                  <dt>手机号：</dt>
                  <dd>
                    <input type="text" id="mobile" name="mobile" class="text w200" />
                    <p class="hint">请输入常用的手机号</p>
                  </dd>
                </dl>

                <dl class="mt15">
                  <dt>推荐人ID：</dt>
                  <dd>
                     <input type="text" id="inviter_id" name="inviter_id"  class="text w200" value="<?php echo $_GET['inviter_id'];?>"/>
                     <p class="hint">请仔细填写您的推荐人ID，注册后不能修改</p>
                  </dd>
                </dl>
                <dl class="mt15">
                  <dt>节点人ID：</dt>
                  <dd>
                     <input type="text" id="node_id" name="node_id"  class="text w200" value="<?php echo $_GET['node_id'];?>"/>
                     <p class="hint">请仔细填写您的节点人ID，注册后不能修改</p>
                  </dd>
                </dl>
                <?php if(C('captcha_status_register') == '1') { ?>
                <div class="code-div mt15">
                  <dl>
                    <dt>验证码：</dt>
                    <dd>
                      <input type="text" id="captcha" name="captcha" class="text w80" size="10" placeholder="<?php echo $lang['login_register_input_code'];?>" />
                    </dd>
                  </dl>
                  <span><img src="index.php?act=seccode&op=makecode&type=50,120&nchash=<?php echo getNchash();?>" name="codeimage" id="codeimage"/> <a class="makecode" href="javascript:void(0)" onclick="javascript:document.getElementById('codeimage').src='index.php?act=seccode&op=makecode&type=50,120&nchash=<?php echo getNchash();?>&t=' + Math.random();"><?php echo $lang['login_password_change_code']; ?></a></span></div>
                <?php } ?>
                <dl class="clause-div">
                  <dd>
                    <input name="agree" type="checkbox" class="checkbox" id="clause" value="1" checked="checked" />
                    <?php echo $lang['login_register_agreed'];?><a href="<?php echo urlShop('document', 'index',array('code'=>'agreement'));?>" target="_blank" class="agreement" title="<?php echo $lang['login_register_agreed'];?>"><?php echo $lang['login_register_agreement'];?></a></dd>
                </dl>
                
                <dl class="bottom">
                    <dt>&nbsp;</dt>
                    <dd>
                      <label class="submit-border">
                        <input class="submit" value="<?php echo $lang['login_register_regist_now'];?>" type="submit">
                      </label>
                    </dd>
                </dl>
                
                
                
                
                <input type="hidden" value="<?php echo $_GET['ref_url']?>" name="ref_url">
                <input name="nchash" type="hidden" value="<?php echo getNchash();?>" />
                
              </form>
            </div>

         
          </div>
        </div>
      </div>
     
    </div>
  </div>
</div>
<script>
$(function(){
    //初始化Input的灰色提示信息
    $('input[tipMsg]').inputTipText({pwd:'password,password_confirm'});
    //注册表单验证
    $("#register_form").validate({
        errorPlacement: function(error, element){
            var error_td = element.parent('dd');
            error_td.append(error);
            element.parents('dl:first').addClass('error');
        },
        success: function(label) {
            label.parents('dl:first').removeClass('error').find('label').remove();
        },
    	submitHandler:function(form){
    	    ajaxpost('register_form', '', '', 'onerror');
    	},
        onkeyup: false,
        rules : {
            user_name : {
                required : true,
                lettersmin : true,
                lettersmax : true,
                letters_name : true,
                remote   : {
                    url :'index.php?act=login&op=check_member&column=ok',
                    type:'get',
                    data:{
                        user_name : function(){
                            return $('#user_name').val();
                        }
                    }
                }
            },
            password : {
                required : true,
                minlength: 6,
		maxlength: 20
            },
            password_confirm : {
                required : true,
                equalTo  : '#password'
            },
            email : {
                required : true,
                email    : true,
                remote   : {
                    url : 'index.php?act=login&op=check_email',
                    type: 'get',
                    data:{
                        email : function(){
                            return $('#email').val();
                        }
                    }
                }
            },
	<?php if(C('captcha_status_register') == '1') { ?>
            captcha : {
                required : true,
                remote   : {
                    url : 'index.php?act=seccode&op=check&nchash=<?php echo getNchash();?>',
                    type: 'get',
                    data:{
                        captcha : function(){
                            return $('#captcha').val();
                        }
                    },
                    complete: function(data) {
                        if(data.responseText == 'false') {
                        	document.getElementById('codeimage').src='index.php?act=seccode&op=makecode&type=50,120&nchash=<?php echo getNchash();?>&t=' + Math.random();
                        }
                    }
                }
            },
			<?php } ?>
            agree : {
                required : true
            }
        },
        messages : {
            user_name : {
                required : '<i class="icon-exclamation-sign"></i><?php echo $lang['login_register_input_username'];?>',
                lettersmin : '<i class="icon-exclamation-sign"></i><?php echo $lang['login_register_username_range'];?>',
                lettersmax : '<i class="icon-exclamation-sign"></i><?php echo $lang['login_register_username_range'];?>',
				letters_name: '<i class="icon-exclamation-sign"></i><?php echo $lang['login_register_username_lettersonly'];?>',
				remote	 : '<i class="icon-exclamation-sign"></i><?php echo $lang['login_register_username_exists'];?>'
            },
            password  : {
                required : '<i class="icon-exclamation-sign"></i><?php echo $lang['login_register_input_password'];?>',
                minlength: '<i class="icon-exclamation-sign"></i><?php echo $lang['login_register_password_range'];?>',
				maxlength: '<i class="icon-exclamation-sign"></i><?php echo $lang['login_register_password_range'];?>'
            },
            password_confirm : {
                required : '<i class="icon-exclamation-sign"></i><?php echo $lang['login_register_input_password_again'];?>',
                equalTo  : '<i class="icon-exclamation-sign"></i><?php echo $lang['login_register_password_not_same'];?>'
            },
            email : {
                required : '<i class="icon-exclamation-sign"></i><?php echo $lang['login_register_input_email'];?>',
                email    : '<i class="icon-exclamation-sign"></i><?php echo $lang['login_register_invalid_email'];?>',
				remote	 : '<i class="icon-exclamation-sign"></i><?php echo $lang['login_register_email_exists'];?>'
            },
			<?php if(C('captcha_status_register') == '1') { ?>
            captcha : {
                required : '<i class="icon-remove-circle" title="<?php echo $lang['login_register_input_text_in_image'];?>"></i>',
				remote	 : '<i class="icon-remove-circle" title="<?php echo $lang['login_register_code_wrong'];?>"></i>'
            },
			<?php } ?>
            agree : {
                required : '<i class="icon-exclamation-sign"></i><?php echo $lang['login_register_must_agree'];?>'
            }
        }
    });
});
</script>
<?php if (C('sms_register') == 1){?>
<script type="text/javascript" src="<?php echo LOGIN_RESOURCE_SITE_URL;?>/js/connect_sms.js" charset="utf-8"></script> 
<script>
$(function(){
	$("#submitBtn").click(function(){
        if($("#post_form").valid()){
            check_captcha();
    	}
	});
	$("#post_form").validate({
        errorPlacement: function(error, element){
            var error_td = element.parent('dd');
            error_td.append(error);
            element.parents('dl:first').addClass('error');
        },
        success: function(label) {
            label.parents('dl:first').removeClass('error').find('label').remove();
        },
        onkeyup: false,
		rules: {
			phone: {
                required : true,
                mobile : true
            },
			captcha : {
                required : true,
                minlength: 4,
                remote   : {
                    url : 'index.php?act=seccode&op=check&nchash=<?php echo getNchash();?>',
                    type: 'get',
                    data:{
                        captcha : function(){
                            return $('#image_captcha').val();
                        }
                    },
                    complete: function(data) {
                        if(data.responseText == 'false') {
                        	document.getElementById('sms_codeimage').src='index.php?act=seccode&op=makecode&type=50,120&nchash=<?php echo getNchash();?>&t=' + Math.random();
                        }
                    }
                }
            },
			sms_captcha: {
                required : function(element) {
                    return $("#image_captcha").val().length == 4;
                },
                minlength: 6
            }
		},
		messages: {
			phone: {
                required : '<i class="icon-exclamation-sign"></i>输入正确的手机号',
                mobile : '<i class="icon-exclamation-sign"></i>输入正确的手机号'
            },
			captcha : {
                required : '<i class="icon-remove-circle" title="<?php echo $lang['login_register_input_text_in_image'];?>"></i>',
                minlength: '<i class="icon-remove-circle" title="<?php echo $lang['login_register_input_text_in_image'];?>"></i>',
				remote	 : '<i class="icon-remove-circle" title="<?php echo $lang['login_register_code_wrong'];?>"></i>'
            },
			sms_captcha: {
                required : '<i class="icon-exclamation-sign"></i>请输入六位短信动态码',
                minlength: '<i class="icon-exclamation-sign"></i>请输入六位短信动态码'
            }
		}
	});
    $('#register_sms_form').validate({
        errorPlacement: function(error, element){
            var error_td = element.parent('dd');
            error_td.append(error);
            element.parents('dl:first').addClass('error');
        },
        success: function(label) {
            label.parents('dl:first').removeClass('error').find('label').remove();
        },
    	submitHandler:function(form){
    	    ajaxpost('register_sms_form', '', '', 'onerror');
    	},
        rules : {
            member_name : {
                required : true,
                lettersmin : true,
                lettersmax : true,
                letters_name : true,
                remote   : {
                    url :'index.php?act=login&op=check_member&column=ok',
                    type:'get',
                    data:{
                        user_name : function(){
                            return $('#member_name').val();
                        }
                    }
                }
            },
            password : {
                required   : true,
                minlength: 6,
				maxlength: 20
            },
            email : {
                email    : true,
                remote   : {
                    url : 'index.php?act=login&op=check_email',
                    type: 'get',
                    data:{
                        email : function(){
                            return $('#sms_email').val();
                        }
                    }
                }
            },
            agree : {
                required : true
            }
        },
        messages : {
            member_name : {
                required : '<i class="icon-exclamation-sign"></i><?php echo $lang['login_register_input_username'];?>',
                lettersmin : '<i class="icon-exclamation-sign"></i><?php echo $lang['login_register_username_range'];?>',
                lettersmax : '<i class="icon-exclamation-sign"></i><?php echo $lang['login_register_username_range'];?>',
				letters_name: '<i class="icon-exclamation-sign"></i><?php echo $lang['login_register_username_lettersonly'];?>',
				remote	 : '<i class="icon-exclamation-sign"></i><?php echo $lang['login_register_username_exists'];?>'
            },
            password  : {
                required : '<i class="icon-exclamation-sign"></i><?php echo $lang['login_register_input_password'];?>',
                minlength: '<i class="icon-exclamation-sign"></i><?php echo $lang['login_register_password_range'];?>',
				maxlength: '<i class="icon-exclamation-sign"></i><?php echo $lang['login_register_password_range'];?>'
            },
            email : {
                email    : '<i class="icon-exclamation-sign"></i><?php echo $lang['login_register_invalid_email'];?>',
				remote	 : '<i class="icon-exclamation-sign"></i><?php echo $lang['login_register_email_exists'];?>'
            },
            agree : {
                required : '<i class="icon-exclamation-sign"></i><?php echo $lang['login_register_must_agree'];?>'
            }
        }
    });
});
</script>
<?php } ?>
